package cn.lzd.mr.case10;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * Created by lzd on 2019/7/16.
 */
public class TextAComparator extends WritableComparator {

    public TextAComparator() {
        super(Text.class, true);
    }


    public int compare(WritableComparable a, WritableComparable b) {
        Text bean1 = (Text) a;
        Text bean2 = (Text) b;

        String[] split1 = bean1.toString().split(",");
        String[] split2 = bean2.toString().split(",");

        return split1[0].compareTo(split2[0]);
    }

}
